// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import FastClick from 'fastclick'
import VueRouter from 'vue-router'
import App from './App'
import VueCorvova from 'vue-cordova'
import routes from './router'
import store from './store';
import {
  inArray
} from './util'


// import Vconsole from 'vconsole'
// new Vconsole()




const router = routes
router.beforeResolve((to, from, next) => {
  if (to.matched.some(record => record.meta.requireAuth)) { // 判断该路由是否需要登录权限

    if (store.state.info) { // 判断当前的token是否存在
      next();
    } else {
      store.commit('updateinfo')
      next({
        path: '/login',
        query: {
          redirect: to.fullPath
        }
      })
    }
  } else {
    next();
  }
});

router.beforeResolve((to, from, next) => {
  if (to.matched.some(record => record.meta.jursidiction)) { // 判断该路由是否需要登录权限
    if (inArray(to.fullPath, store.state.info.jursidiction)) { // 判断当前的token是否存在
      next();
    } else {
      next({
        path: '/404',
      })
    }
  } else {
    next();
  }
});
Vue.prototype.$devicePixelRatio = 2
Vue.use(VueCorvova)
FastClick.attach(document.body)

Vue.config.productionTip = false

/* eslint-disable no-new */
new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app-box')
